package com.lagou.sqlSession;


import com.lagou.config.XMLConfigBuilder;
import com.lagou.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {


  public SqlSessionFactory getBuild(InputStream in) throws PropertyVetoException, DocumentException, ClassNotFoundException {

        //1.dom4j解析文件到configuration 中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parceConfig(in);
        //2.创建sqlSessionFactory对象   工厂类： 生产sqlSession 会话对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return defaultSqlSessionFactory;
    }
}
